feat(audit): implement platform-wide audit logging#302
Conversation
9f87238 to
0963c3a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f87238fd2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setCursor(nextCursor); | ||
| load('next').catch(() => {}); |
There was a problem hiding this comment.
Use updated cursor when loading next audit log page
This handler sets cursor and immediately calls load('next'), but load reads query from the current render before the state update is applied. When users click “Load more” from the first page, the request is sent with the old cursor (undefined), so page 1 is fetched again and appended as duplicates; similar stale-state behavior also affects other flows that call setCursor(...) and then load(...) synchronously. Pass the next cursor directly into load (or trigger loading from cursor changes) so pagination requests always use the intended cursor.
Useful? React with 👍 / 👎.
| import { AuditLogService } from './audit-log.service'; | ||
| import { | ||
| ListAuditLogsQuerySchema, | ||
| type ListAuditLogsQueryDto, |
There was a problem hiding this comment.
Import audit query DTO as value for OpenAPI reflection
Using a type-only import for ListAuditLogsQueryDto strips the runtime class reference that Swagger relies on for @Query metadata, so this commit’s generated schema omits all /audit-logs query params (and the generated backend client shows query?: never for AuditLogsController_list). That makes typed SDK consumers unable to pass filters/cursor/limit even though the endpoint supports them; import the DTO as a value (or add explicit @ApiQuery declarations) to keep the contract accurate.
Useful? React with 👍 / 👎.
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
- Remove duplicate ApiKeyPermissions interface from auth/types.ts (now imported from schema) - Add missing audit permission to controller and service spec mocks - Add auditLogService arg to WorkflowsService constructor in run-status-cache spec Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Records create, update, delete, pause, resume, and trigger events for workflow schedules. Extends AuditResourceType with 'schedule', 'mcp_server', 'mcp_group', and 'human_input' resource types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Records create, update, toggle, and delete events for MCP servers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Records create, update, delete, and import_template events for MCP groups. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Records human_input.resolve for both authenticated and public-token resolution paths, capturing approval status and responder identity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Previously all mcp_group audit events recorded null actor because auth was discarded in the controller with _auth. Similarly, human_input.resolve was not tracking the actor. - Add auth param to createGroup, updateGroup, deleteGroup, importTemplate - Pass auth through from controller for all mutating mcp-group endpoints - Add auth param to human-inputs resolve() for actor tracking - resolveByToken correctly keeps null auth (genuinely unauthenticated) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
- Add schedule, mcp_server, mcp_group, human_input to AuditResourceTypeSchema - Fix HumanInputsService test constructor call (added AuditLogService param) - Fix SchedulesService test constructor call (added AuditLogService param) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
d1f450d to
eca26eb
Compare
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Summary
Platform-wide audit logging implementation for ShipSec Studio.
Core infrastructure (
feat(audit): implement platform-wide audit logging)AuditLogService— fire-and-forget viaqueueMicrotask, never blocks requestsAuditLogsController— paginated list endpoint with cursor-based pagination (GET /audit-logs)audit_logstable with actor, action, resource, IP, user-agent, metadata@Global()module — injectAuditLogServiceanywhere without module importsuserId,organizationId,actorType(user|api-key|internal|unknown), IP, user-agent from request contextResource coverage
workflowcreate,update,delete,run,cancelsecretcreate,update,deleteapi_keycreate,deletewebhookcreate,update,deleteartifactdownloadschedulecreate,update,delete,pause,resume,triggermcp_servercreate,update,toggle,deletemcp_groupcreate,update,delete,import_templatehuman_inputresolveAuth context threading (
fix(audit): thread auth context through mcp-groups and human-inputs)@CurrentAuth()via unused_authparam — fixedcreateGroup,updateGroup,deleteGroup,importTemplatenow propagate real actor to audit logHumanInputsService.resolve()accepts optionalauthparam; controller threads it throughresolveByToken(public token endpoint) correctly recordsnullactorType system fixes
AuditResourceTypeunion in DB schema with 4 new typesAuditResourceTypeSchemaZod enum in sync to avoid TS2322 in controllerAuditLogServiceconstructor argTest plan
tsc --build)record()calls are fire-and-forget — no request latency impactGET /audit-logsreturns paginated entries filtered by org🤖 Generated with Claude Code